# vim:set ts=2:noet:
include ../common.mk
bdir=generated

.PHONY: all install clean

all: $(bdir)/manpages.stamp

install: $(bdir)/manpages.stamp
	for man in $(bdir)/apt-listchanges*.1; do \
		test -s "$$f"; \
		lang=`echo $$man | sed -e 's/^.*apt-listchanges\.*// ; s/\.*1//'`; \
		install -d $(DESTDIR)/usr/share/man/$$lang/man1;                \
		install -m 644 $$man $(DESTDIR)/usr/share/man/$$lang/man1/apt-listchanges.1; \
	done
clean:
	rm -rf generated

PO4A := PERL_HASH_SEED=0 PERL_PERTURB_KEYS=0 po4a $(XGETTEXT_COMMON_OPTIONS) --previous

update-po:
	$(PO4A) --force -v po4a.cfg

$(bdir)/po4a.stamp:  apt-listchanges.sgml po/*.po po/*.add po4a.cfg
	$(PO4A)  -v po4a.cfg
	touch "$@"

$(bdir)/manpages.stamp: $(bdir)/po4a.stamp
	for f in apt-listchanges.sgml $(bdir)/apt-listchanges.*.sgml; do \
		test -f "$$f" || continue; \
		g="$(bdir)/`basename $$f .sgml`.1"; \
		echo "Creating $$g from $$f"; \
		LC_ALL=C docbook-to-man "$$f" > "$$g"; \
	done
	touch "$@"
